import 'package:flutter/cupertino.dart';
import 'package:flutter/foundation.dart';
import 'package:provider/provider.dart';

enum HttpEnvironment { product, test, dev }

class Configs extends ChangeNotifier {
  HttpEnvironment environment;
  bool isDebug;
  bool addToLogger;
  String imageRoot;
  String fakeDataRoot;

  Configs({
    this.environment = HttpEnvironment.product,
    this.isDebug = true,
    this.addToLogger = true,
    this.imageRoot = "assets/icons",
    this.fakeDataRoot = "http://192.168.11.156:9090/apis/",
  });

  String get httpRoot => "http://27.17.32.138:5063/";

  bool isProductionEnvironment() =>
      environment == HttpEnvironment.product && isDebug == false;

  bool isTestEnvironment() => environment == HttpEnvironment.test;

  bool isDevEnvironment() => HttpEnvironment.dev == environment;

  String getVersionPrefix() {
    switch (environment) {
      case HttpEnvironment.product:
        return isDebug ? "product-" : "";
      case HttpEnvironment.test:
        return "test-";
      case HttpEnvironment.dev:
        return "dev-";
    }
  }

  static Configs of(BuildContext context, [bool listen = false]) =>
      Provider.of<Configs>(context, listen: listen);
}
